﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace nLearning
{
    /// <summary>
    /// Interaction logic for cMessage.xaml
    /// </summary>
    public partial class cMessage : Window
    {
        public cMessage(string msg,BUTTON_TYPE button)
        {
            InitializeComponent();
            _message = msg;
            _button = button;
        }

        public enum BUTTON_TYPE
        {
            OK,
            YESNO,
            OKCANCEL
        }

        private string _message = "_undefined.";
        private BUTTON_TYPE _button = BUTTON_TYPE.OK;

        private void btOK_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
            this.Close();
        }

        #region set button label
        private void DrawOK()
        {
            btAbort.Visibility = System.Windows.Visibility.Hidden;
            btOK.Content = "OK";
        }
        private void DrawOKCANCEL()
        {
            btOK.Content = "OK";
            btAbort.Content = "Cancel";
        }
        private void DrawYESNO()
        {
            btOK.Content = "Yes";
            btAbort.Content = "No";
        }
        #endregion
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            txtMsg.Text = _message;
            switch (_button)
            {
                case BUTTON_TYPE.OK: DrawOK();
                    break;
                case BUTTON_TYPE.OKCANCEL: DrawOKCANCEL();
                    break;
                case BUTTON_TYPE.YESNO: DrawYESNO();
                    break;
                default: DrawOK();
                    break;
            }
        }

        private void btAbort_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }
    }
}
